/**
 * author: zhangwei
 * 角色管理列表
 */
var main = {

    init: function() {
        this.initTable();
        this.tabBind();
    },
    initTable: function() {
        var _this=this;
        loadTable();

    },
    tabBind: function() {
        layui.use(['form'], function () {
            var form = layui.form;
            form.on('submit(formDemo)', function(data){
                loadTable();
                return false;
            });

        });
    }
}
main.init();

function loadTable() {
    layui.use('table', function(){
        var table = layui.table;
        var form = layui.form;
        var status = $("#status").val()
        table.render({
            elem: '#test'
            ,url:"/task/getMyTask?status="+status
            ,title: '数据表'
            ,cols: [[
                {field:'taskName', title:'任务名称'}
                ,{field:'jobStr', title:'岗位名称'}

                ,{field:'startTime', title:'开始时间', templet: function (res) {
                        return formatSimpleDate(res.startTime);
                    }}
                ,
                {field:'endTime', title:'结束时间', templet: function (res) {
                        return formatSimpleDate(res.endTime);
                    }}
                ,{field:'status', title:'完成状态', templet: function (res) {
                    if (res.status == 1){
                        return '已完成'
                    } else{
                        return '未完成'
                    }
                }
                }

                ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:200}
            ]]
            ,page: true
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
             if (obj.event === 'edit'){
                localStorage.taskType = "edit";
                localStorage.taskId = data.id;
                parent.$t.goToPage(this, "/task/myTask");
            }
        });
    });
}

